using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Overzicht : System.Web.UI.Page
{

    private String Gebruiker;
    Databank db;
    SessionGebruiker sg;


    protected void Page_Load(object sender, EventArgs e)
    {
        db = Databank.DatabankInstantie;

        Getuserstuff();
        if (Gebruiker == "davy.coopman@howest.be")
        {
            TestPanel.Visible = true;
        }
        else
        {
            TestPanel.Visible = false;
        }
    }


    private void GeefJuisteMenu()
    {
        MultiView1.ActiveViewIndex = 1;
        Menu.Items.Clear();
        int[] recht = new int[4];

        Menu.Items.Add(new MenuItem("Mijn Agenda", "MA"));
        Menu.Items.Add(new MenuItem("Upload", "UP"));

        for (int i = 0; i < sg.Rollen.Count; i++)
        {
            string rol = sg.Rollen[i];
            switch (rol)
            {
                case "student" :
                    Menu.Items.Add(new MenuItem("Student Panel", "S"));
                    break;
                case  "Lector" :
                    Menu.Items.Add(new MenuItem("Lector Panel", "L"));
                    break;
                default :
                    break;
            }
        }

        bool mentor = db.Ismentor(Gebruiker);
        if (mentor)
        {
            Menu.Items.Add(new MenuItem("Mentor Panel","M"));
        }

        bool coordi = db.IsCoordinator(Gebruiker);
        if (coordi)
        {
            Menu.Items.Add(new MenuItem("Globaal Panel", "G"));
        }

        bool beheerder = db.IsBeheerder(Gebruiker);
        if (beheerder)
        {
            Menu.Items.Add(new MenuItem("Admin Panel", "ADMIN"));
        }

    }



    private void Getuserstuff()
    {

        sg = (SessionGebruiker)Session["login"];
        if (sg != null)
        {
            Gebruiker = sg.Gebruiker;
            GeefJuisteMenu();
        }
        else
        {
            MultiView1.ActiveViewIndex = 0;
        }
    }
    protected void Menu_MenuItemClick(object sender, MenuEventArgs e)
    {
        switch (Menu.SelectedItem.Value)
        {
            case "S" :
                Response.Redirect("Student.aspx");
                break;
            case "L":
                Response.Redirect("Lector.aspx");
                break;
            case "M":
                Response.Redirect("Mentor.aspx");
                break;
            case "G":
                Response.Redirect("Globaal.aspx");
                break;
            case "ADMIN" :
                Response.Redirect("admin.aspx");
                break;
            case "MA":
                Response.Redirect("agenda.aspx");
                break;
            case "UP":
                Response.Redirect("upload.aspx");
                break;

        }
    }
}
